<template>
  <div class="send-setting-dialog">
    <el-dialog :visible.sync="$attrs.visableIf" @close="handleCloseDialog" :close-on-click-modal="false"
      :close-on-press-escape="false" append-to-body width="64%">
      <div slot="title" style="font-size: 14px;font-weight: 500;">
        发送设置
      </div>
      <div class="content-big">
        <div class="content-right">
          <div class="table-head">
            <el-input v-model="queryParams.userName1" size="small" placeholder="搜索企微号" style="width: 200px;" clearable
              @keyup.enter.native="handleQuery" suffix-icon="el-icon-search" />
            <el-select v-model="queryParams.userName2" size="small" style="margin-left: 10px " filterable
              placeholder="请选择分组" @change="handleQuery">
              <el-option v-for="item in groupList" :key="item.value" :label="item.label" :value="item.value">
              </el-option>
            </el-select>
          </div>
          <el-table :data="tableDataList" ref="companylabelList" tooltip-effect="dark">
            <el-table-column type="selection" width="55" />
            <el-table-column prop="name">
              <template slot="header" slot-scope="scope">
                <span>企微信号</span>
                <el-tooltip class="item" effect="dark" content="有管理权限的所有企微号" placement="top">
                  <svg-icon icon-class="question" style="margin-left: 4px;" />
                </el-tooltip>
              </template>
              <div class="userInfo">
                <img src="@/assets/images/profile.jpg" />
                <div class="user-big">
                  <div class="name">群聊</div>
                  <div class="label">成员<span>3</span></div>
                </div>
              </div>
            </el-table-column>
            <el-table-column prop="sendTime">
              <template slot="header" slot-scope="scope">
                <span>对象发送间隔</span>
                <el-tooltip class="item" effect="dark" placement="top">
                  <div slot="content">从上一个对象执行完成到下一个对象<br />开始执行的间隔时间。</div>
                  <svg-icon icon-class="question" style="margin-left: 4px;" />
                </el-tooltip>
              </template>
            </el-table-column>
            <el-table-column prop="msgTime">
              <template slot="header" slot-scope="scope">
                <span>消息发送间隔 </span>
                <el-tooltip class="item" effect="dark" placement="top">
                  <div slot="content">同一个对象的上一条消息发送完毕到<br />下一条消息开始发送的间隔时间</div>
                  <svg-icon icon-class="question" style="margin-left: 4px;" />
                </el-tooltip>
              </template>
            </el-table-column>
            <el-table-column prop="sleepTime">
              <template slot="header" slot-scope="scope">
                <span>休眠时段 </span>
                <el-tooltip class="item" effect="dark" placement="top">
                  <div slot="content">休眠时间段内不发送，休眠结束自动<br />恢复。</div>
                  <svg-icon icon-class="question" style="margin-left: 4px;" />
                </el-tooltip>
              </template>
            </el-table-column>
            <el-table-column prop="dayDate">
              <template slot="header" slot-scope="scope">
                <span>每个对象日发送任务上限 </span>
                <el-tooltip class="item" effect="dark" placement="top">
                  <div slot="content">每个自然日，每个对象能够发送的高<br />级群发任务数上限</div>
                  <svg-icon icon-class="question" style="margin-left: 4px;" />
                </el-tooltip>
              </template>
            </el-table-column>
            <el-table-column fixed="right" label="操作" width="100">
              <template slot-scope="scope">
                <el-button @click="handleSetting(scope.row)" type="text" size="small">设置</el-button>
              </template>
            </el-table-column>
          </el-table>
          <pagination v-show="total > 10" :total="total" :page.sync="queryParams.pageNum"
            :limit.sync="queryParams.pageSize" @pagination="getList" />
        </div>
      </div>
      <div class="footer-box" slot="footer">
        <div class="option-row" style="gap: 8px;">
          <div class="row-item">
            <span>选择全部</span>
          </div>
          <div class="row-item">
            已选：<span>0</span>个
          </div>
          <div class="row-item">
            <el-button size="small">批量操作</el-button>
          </div>
        </div>
      </div>
      <setSendPage v-if="showSetSendPage" :visableIf.sync="showSetSendPage"></setSendPage>
    </el-dialog>
  </div>
</template>

<script>


import { listUser } from "@/api/system/user";


export default {
  name: 'editSendSettings',
  components: {
    'setSendPage': () => import('./setSendPage.vue'),//导出弹窗
  },
  data() {
    return {
      // 查询参数
      showSetSendPage: false,
      input3: null,//群查找
      radio: null,//
      groupList: [
        {
          value: '0',
          label: '志新'
        }, {
          value: '1',
          label: '锐行'
        }
      ],
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        userName1: null,
        userName2: null,
        userName3: null,
        userName4: null,
        userName5: null,
        userName6: null,
        userName7: null,
        userName8: null,
        userName9: null,
        userName10: null,
        userName11: null,
        userName12: null,
        userName13: null,
        userName14: null,
      },
      callList: [
        //称呼
        { id: 1, name: "有" },
        { id: 2, name: "无" },
      ],
      tableColumns: [
        { key: 'name', label: `企微号`, visible: true, minWidth: 150, fixed: true },
        { key: 'name2', label: `触发延迟`, visible: true, minWidth: 150, fixed: true },
        { key: 'status', label: `休眠时段`, visible: true, minWidth: 150, fixed: true },
      ],
      tableDataList: [],
      total: 8, // 表格的总条数
      multipleSelection: [],//表格多选
      showSelectSmartTags: false,//智能标签
      tableHeight: 600,
      dateRange1: [],
    }
  },
  created() {
    this.tableDataList = [];
    for (let i = 0; i < 10; i++) {
      let obj = {
        name: '小红',
        name2: '18207418337',
        status: '是',
      }
      this.tableDataList.push(obj);
    }
  },
  mounted() {

  },
  watch: {},
  methods: {
    /** 查询用户列表 */
    getList() {
      this.loading = true;
      listUser(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
        this.userList = response.rows;
        this.total = response.total;
        this.loading = false;
      }
      );
    },
    // 表单重置
    reset() {
      this.form = {
        userId: undefined,
        deptId: undefined,
        userName: undefined,
        nickName: undefined,
        password: undefined,
        phonenumber: undefined,
        email: undefined,
        sex: undefined,
        status: "0",
        remark: undefined,
        postIds: [],
        roleIds: []
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    handleSetting(row) {
      this.showSetSendPage = true;
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.queryParams.deptId = undefined;
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(val) {
      this.multipleSelection = [];
      if (val && val.length > 0) {
        val.forEach((item) => {
          this.multipleSelection.push(item.id);
        })
      }
    },
    handleApplication(row) {
      //应用
    },
    handleStatusChange(row) {

    },
    handleCloseDialog() {
      this.$emit('update:visableIf', false);
      this.$emit('handleQuery');
    },
  }
}
</script>

<style scoped lang="scss" scope>
.number {
  position: absolute;
  left: 10px;
  top: 0px;
  font-size: 14px;

  span {
    color: rgba(0, 0, 0, .65);
    color: rgb(240, 139, 0);
  }

  .el-button {
    color: #3370ff;
    border: none;
  }
}

.userInfo {
  border-radius: 4px;
  margin: 8px 0;
  cursor: pointer;
  position: relative;
  padding-left: 50px;
  font-size: 14px;
  list-style: none;
  text-align: left;
  display: flex;
  align-items: center;
  justify-items: center;

  img {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    left: 0px;
    top: 0px;
    position: absolute;
  }

  .label {
    margin-top: 2px;
    font-size: 12px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #f90;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .user-big {
    display: flex;
    flex-direction: column;
    line-height: 18px;
  }
}

.content-big {
  display: flex;
  height: 100%;

  .content-left {
    width: 410px;
    background: #fff;
    border-right: 1px solid #eee;

    .title {
      background: #f5f5f5;
      color: #2f333c;
      font-weight: 700;
      padding: 12px 20px;
      display: flex;
      align-items: center;
      justify-content: space-between;
    }

  }

  .content-right {
    flex: 1;

    .table-head {
      display: flex;
      align-items: center;
      height: 60px;
    }
  }
}

::v-deep .el-dialog__body {
  overflow-y: auto;
  max-height: 600px;
  padding: 20px 20px;
}

.title-tips {
  position: absolute;
  top: -0px;
  left: 90px;
  height: 45px;
  display: flex;
  align-items: center;
  justify-content: center;

  span {
    margin-left: 10px;
    color: #888;
  }
}

.el-checkbox-group {
  margin-top: 20px;

  .el-checkbox {
    margin-bottom: 12px;
    width: 150px;
  }
}

.title {
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 15px;

  span {
    color: #3370ff;
  }
}

.exclusion {
  margin: 12px 0px;
  padding: 12px 16px;
  border-radius: 2px;
  border: 1px solid #f0f0f0;
}

::v-deep .el-dialog__footer {
  background: #ffffff;
  border-top: none;
}

.footer-box {
  height: 100%;
  width: 100%;

  .option-row {
    display: flex;
    height: 100%;
    align-items: center;
    font-size: 14px;
    line-height: 22px;

    .row-item {
      span {
        color: #3070ff;
      }
    }
  }
}
</style>
